
#include "StdAfx.h"
#include "BoundaryValue.h"

BoundaryValue::BoundaryValue(){	
}

BoundaryValue::~BoundaryValue(){
}

bool BoundaryValue::is_exist_boundary( int start, int end ){
	DefineValue* pDefine = 0;
	int size = define_.size();

	for( int i = 0; i < size; i++ ){
		pDefine = &define_[ i ];

		if( pDefine->start == start && pDefine->end == end )
			return true;
	}
	return false;
}

void BoundaryValue::register_value( int start, int end, int value ){
	DefineValue define;
	define.start = start;
	define.end = end;
	define.value = value;

	define_.push_back( define );
}

void BoundaryValue::modify_value( int start, int end, int value ){
	DefineValue* pDefine = 0;
	int size = define_.size();

	for( int i = 0; i < size; i++ ){
		pDefine = &define_[ i ];

		if( pDefine->start == start && pDefine->end == end )
			pDefine->value = value;		
	}
}

int BoundaryValue::get_value( int value ){
	DefineValue define;
	int size = define_.size();

	for( int i = 0 ; i < size ; i++ ){
		define = define_[ i ];

		if( isInclusion( define.start, define.end, value ) )
			return define.value;
	}

	return 0;
}

bool BoundaryValue::isInclusion( int start, int end, int value ){
	if( ( value >= start ) && ( value <= end ) )
		return true;
	return false;
}